package com.banksystem.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.banksystem.Util.TokenUtil;
import com.banksystem.entity.Group;
import com.banksystem.service.Groupservice;

@Controller
public class stglController {
	@Autowired
	private Groupservice service;
	@Autowired
	private TokenUtil tokenUtil;
	
	/*
	 * 添加社团信息
	 */
	@RequestMapping("addstxx")
	public String addstxx() {
		return "stxxgl/addstxx";
	}
	@RequestMapping("addst")
	public String addst(String name,String type,String date ,String master,String phone,String uname,String password,String intro){
		service.addst(name, type, date, master, phone, uname,password,intro);
		return "stxxgl/addstxx";
	}
	/*
	 * 社团信息管理
	 */
	@RequestMapping("stxxgl")
	public String stxxgl(Model mv) {
		mv.addAttribute("grouplist", service.findstxx());
		return "stxxgl/stxxgl";
	}
	/*
	 * 社团信息（负责人）
	 */
	@RequestMapping("fzrstxx")
	public String fzrstxx(Model mv,HttpServletRequest request) {
		String username=tokenUtil.findUsernameBytoken(request);
		Group group=service.findstxxAll(username);
		mv.addAttribute("group", group);
		return "stxxgl/fzrstxx";
	}
	/*
	 * 删除社团
	 */
	@RequestMapping("detelest")
	public String detelenews(String gid) {
		service.detelest(gid);
		return "forward:stxxgl.do";
	}
	@RequestMapping("seachgroup")
	public @ResponseBody List<Group> seach(String seach) {
		List<Group> list=service.findgroup(seach);
		return list;
	}
	
}
